package com.book.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.book.dao.BookInfoDao;
import com.book.entity.BookInfo;
import com.book.service.BookInfoService;
@Service
public class BookInfoServiceImpl implements BookInfoService {

	/**
	 * @Transactional 用在类上，方便但不灵活 
	 * 用在方法上，灵活，麻烦，每个方法都要配置
	 */
	
	@Resource(name="bookInfoDaoImpl")
	private BookInfoDao bookInfoDao;
	
	@Override
	@Transactional(readOnly=true)
	public BookInfo findById(Integer id) {
		return bookInfoDao.findById(id);
	}

	public BookInfoDao getBookInfoDao() {
		return bookInfoDao;
	}

	public void setBookInfoDao(BookInfoDao bookInfoDao) {
		this.bookInfoDao = bookInfoDao;
	}

	@Override
	@Transactional(propagation=Propagation.REQUIRED)
	public void saveOrupdate(BookInfo bookInfo) {
		bookInfoDao.saveOrupdate(bookInfo);
	}
	

}
